
#快慢指针，没有遇到val，两指针+1，遇到val，fast+1，slow不动
#slow 只记录不等于val的个数
def l27(nums,val):
    len1 = len(nums)
    slow = fast = 0
    for i in range(len1):
        #print(nums[i])
        if val == nums[i]:
            fast += 1
        else:
            nums[slow] = nums[i] #非val值前移
            fast += 1
            slow += 1
    print(nums)
    return slow


    pass

if __name__ =='__main__':
    print(l27([3,2,2,3],3))
    print(l27([3,1,2,3,4,5,3,3,9],3))
    pass